﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;

namespace PloobsEngine.SceneControl
{

    public class ContrastPostEffect : IPostEffect
    {
        /// <summary>
        /// 
        /// </summary>
        /// <param name="contrast">-1 a 1</param>
        public ContrastPostEffect(float contrast)
        {
            this.contrast  = contrast;
        }

        #region IPostEffect Members

        Effect effect = null;

        float contrast = 0.5f;
        bool canChange = false;

        public bool CanChange
        {
            get { return canChange; }
            set { canChange = value; }
        }
        public float Contrast
        {
            get { return contrast; }
            set { contrast = value; }
        }

        public void Draw(IRenderHelper rHelper, Microsoft.Xna.Framework.GameTime gt, Microsoft.Xna.Framework.Rectangle screenRec, IWorld world)
        {
            if (canChange)
            {
                if (Keyboard.GetState().IsKeyDown(Keys.L))
                {
                    contrast += 0.1f;
                }
                else if (Keyboard.GetState().IsKeyDown(Keys.K))
                {
                    contrast -= 0.1f;
                }

            }



            effect.Parameters["Contrast"].SetValue(contrast);
            rHelper.RenderTextureToFullScreenSpriteBatch(PrincipalConstants.CurrentImage, effect);
        }

        public void init(EngineStuff engine)
        {
            ///Load the asset
            effect = EngineStuff.InternalContentManager.GetAsset<Effect>("contrast");
            //effect = EngineStuff.CustomContentManager.GetAsset<Effect>("..\\Content\\Effects\\saturation");          
        }

        #endregion

    }
}
